/**
 * 
 */
package com.gragra.sampling.sequentialStructure;
/**
 * @author Christoph Teichmann
 * created Mar 26, 2013 7:26:11 PM
 * @version 0.1
 */
public enum CaseLevel implements ExtensionInformationValue
{
	UpperCase {
		@Override
		protected String getPatt()
		{return "\\p{Upper}[^\\p{Upper}]+";}
	},
	CapsLockCase {
		@Override
		protected String getPatt()
		{return "\\p{Upper}+";}
	},
	CamelCase {
		@Override
		protected String getPatt()
		{return null;}
	},
	DownCase {
		@Override
		protected String getPatt()
		{return "[^\\p{Upper}]+";}
	};
	/* (non-Javadoc)
	 * @see com.gragra.sampling.sequentialStructure.ExtensionInformationValue#getLevel()
	 */
	@Override
	public ExtensionInformationLevel getLevel()
	{return ExtensionLevels.CaseTypeLevel;}
	/* (non-Javadoc)
	 * @see com.gragra.sampling.sequentialStructure.ExtensionInformationValue#getNumber()
	 */
	@Override
	public int getNumber()
	{
		if(number < 0)
		{
			for(int i=0;i<CaseLevel.values().length;++i)
			{
				if(CaseLevel.values()[i] == this)
				{return (number = i);}
			}
		}
		return number;
	}
	/**
	 * 
	 */
	private int number = -1;
	/**
	 *
	 * @param string
	 * @return
	 */
	public static String getValueFor(String string)
	{
		for(int i=0;i<CaseLevel.values().length;++i)
		{
			if(CaseLevel.values()[i] == CamelCase)
			{continue;}
			if(string.matches(CaseLevel.values()[i].getPatt()))
			{return CaseLevel.values()[i].name();}
		}
		return CaseLevel.CamelCase.name();
	}
	/**
	 * 
	 * @return
	 */
	protected abstract String getPatt();
}